package thrift.service.hello;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

public class HelloServiceServer {

    public static void main(String[] args) {
        HelloServiceServer.start();
    }

    public static void start() {
        try {
            System.out.println("Server is starting....");
            TProcessor processor = new HelloService.Processor<HelloService.Iface>(new HelloServiceImpl());
            TServerSocket transport = new TServerSocket(9090);
            TServer.Args args = new TServer.Args(transport);
            args.processor(processor);
            args.protocolFactory(new TBinaryProtocol.Factory());
            TServer server = new TSimpleServer(args);
            server.serve();
        } catch (TTransportException e) {
            e.printStackTrace();
        }
    }
}
